import { $http } from '@/utils';
import { $ResponseCode } from '@/utils/const/env';
export const Dealer = {
    dealer: () => {
        return new Promise((resolve, reject) => {
            $http.get('Dealer/dealer').then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject({ msg: res.msg });
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    applyDealer: () => {
        return new Promise((resolve, reject) => {
            $http.get('Dealer/applyDealer').then((res: any) => {
                resolve(res);
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    getPoster: (query:any) => {
        return new Promise((resolve, reject) => {
            $http.get('Dealer/getPoster',{
                data: query
            }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject({ msg: res.msg });
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    people: (query:any) => {
        return new Promise((resolve, reject) => {
            $http.get('Dealer/people',{
                data: query
            }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject({ msg: res.msg });
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    }
}